Skip to content

Conversation

aedm
Copy link
Member

@aedm aedm commented Oct 6, 2025

Related

What

  • Allows interacting with app state from an integration test using a test hook function
  • Adds a bunch of Rerun-specific utility functions to Kittest
  • Replaces a context menu test from the release checklist as a proof of concept

Copy link

github-actions bot commented Oct 6, 2025

Web viewer built successfully.

Result Commit Link Manifest
2b8e349 https://rerun.io/viewer/pr/11435 +nightly +main

Note: This comment is updated whenever you push a commit.

@aedm aedm added the exclude from changelog PRs with this won't show up in CHANGELOG.md label Oct 6, 2025
@aedm aedm marked this pull request as ready for review October 6, 2025 11:48
Copy link
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really awesome ⭐

Comment on lines 56 to 58
// Prints the current viewer state. Don't merge code that calls this.
#[allow(unused)]
fn debug_viewer_state(&mut self);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not merge code that calls it? Is it very slow?

If it's called from a test, stdout/stderr only reaches the terminal output if the tests fails.

Comment on lines +60 to +70
fn toggle_blueprint_panel(&mut self) {
self.click_label("Blueprint panel toggle");
}

fn toggle_time_panel(&mut self) {
self.click_label("Time panel toggle");
}

fn toggle_selection_panel(&mut self) {
self.click_label("Selection panel toggle");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be a lot nicer to have idempotent commands here, i.e. fn show_blueprint_panel(&mut self, open: bool)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After investigation, it's a bit more complex than I hoped for.
Added tracking issue, will implement as a standalone PR: #11451

Comment on lines +193 to +201
fn click_label(&mut self, label: &str) {
self.get_by_label(label).click();
self.run_ok();
}

fn right_click_label(&mut self, label: &str) {
self.get_by_label(label).click_secondary();
self.run_ok();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate having these helpers to not having to call .run_ok() after each action… but I wish we had this in kittest instrad. kittest allows user to buffer up many inputs (e.g. push down some modifiers before clicking), which is powerful, but the price is all these manual calls to .run(). And realistically, you almost shouldn't test clicking two things in the same frame, since realistically that shouldn't happen in real usage.

In other words: I believe kittest's API is a bit too low-level for most tests.

I don't think there is anything actionable here, except food for thought, and ping @lucasmerlin

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually kittest runs all queued up events in seperate steps (so you could click a text edit, type some text and then click a button, and all the events would happen on seperate frames, even if you only call run() once).
But this is really not obvious, so theres definitely room for improvements in that.

And to make it run automatically on clicks, kittest would require a lot of interior mutability, which might make some other apis kind of awkward. But maybe it'd be nice, then we could also hold Nodes across run() calls (so you don't have to re-query them all the time).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually kittest runs all queued up events in seperate steps

So why are the .run_ok() calls even needed here then?

pub async fn test_single_text_document() {
let mut harness = viewer_test_utils::viewer_harness();
harness.init_recording();
harness.toggle_selection_panel();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this is the problem with non-idempotency. Is this opening or closing the selection panel? 🤷

@aedm aedm merged commit d4f8950 into main Oct 7, 2025
40 checks passed
@aedm aedm deleted the aedm/app-test-with-blueprints branch October 7, 2025 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude from changelog PRs with this won't show up in CHANGELOG.md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants